package com.sina.shop.web;


import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

/**
 * <p>
 *     分布参数的表单对象
 * </p>
 *
 * @version 1.0
 */
public class PagingForm extends Form {

    /**
     * default 1 in getter, not null
     */
    @Min(value = 1, message = "page >= 1")
    private Integer page;

    /**
     * default 5 in getter,not null
     */
    @Min(value = 1, message = "rows >= 1")
    @Max(value = 500)
    private Integer rows;


    public PagingForm() {

    }

    /**
     *
     * @return 当前页号,如果 page 为 null ,返回默认的 1
     */
    public Integer getPage() {
        if (page == null) {
            page = 1;
        }
        return page;
    }

    public PagingForm setPage(Integer page) {
        this.page = page;
        return this;
    }

    /**
     *
     * @return 返回 当前页的尺寸,或为 null ，则返回默认的 5
     */
    public Integer getRows() {
        if (rows == null) {
            rows = 5;
        }
        return rows;
    }

    public PagingForm setRows(Integer rows) {
        this.rows = rows;
        return this;
    }
}
